package newJdk8;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @program: javase
 * @description: 四大函数式接口
 * @author: lld
 * @create: 2021-04-20 21:40
 **/
public class fourFunInterface {
    public static void main(String[] args) {
        //function 有参数，有返回值
        Function apply = (a) -> {
            return a;
        };
//        Function apply = new Function<Integer,Integer>() {
//            @Override
//            public Integer apply(Integer o) {
//                return o;
//            }
//        };
        System.out.println(apply.apply(1));
        //predicate 有参数，返回值为布尔类型
        Predicate predicate = (x) -> {
            return x == "1";
        };
        System.out.println("predicate.test(\"2\") = " + predicate.test("2"));
        //consumer 有参数，无返回值
        Consumer<Integer> consumer = (t) -> {
            System.out.println(t + 1);
        };

        Supplier<String> supplier = () -> {
            return "666";
        };

    }
}
